#ifndef TINX_TYPES_H
#define TINX_TYPES_H

#include <tinx/errno.h>

typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;

typedef void *handler_t;

typedef u32 time_t;
typedef int16 fd_t;

typedef int16 pid_t;
typedef int16 uid_t;

typedef int size_t;
typedef int32 idx_t;

typedef int16 dev_t;
typedef int8 flag_t;

#define bool int
#define true 1
#define false 0

#define CONCAT(x, y) x##y
#define RESERVED_TOKEN(x, y) CONCAT(x, y)
#define RESERVED RESERVED_TOKEN(reserved, __LINE__)

#define NULL ((void *)0)
#define EOF (-1)
#define EOS '\0'

#define BMB asm volatile("xchgw %bx, %bx")
#define NOP asm volatile("nop\n")

#define _packed __attribute__((packed))
#define _aligned(n) __attribute__((aligned(n)))
#define _noreturn __attribute__((noreturn))

#define TINX_MAGIC 0x20250601

// 标准文件描述符
typedef enum std_fd_t
{
    STDIN_FILENO,
    STDOUT_FILENO,
    STDERR_FILENO,
} std_fd_t;

typedef struct iovec_t
{
    void *base;
    size_t len;
} iovec_t;

#endif